using NUnit.Framework;

// ReSharper disable InconsistentNaming
namespace NFreeMarker.Tests.Template
{
    public class TemplateTests_ProcessBuiltInsForBooleans
    {
        [TestFixture]
        public class When_processing_a_string_builtin : TemplateTestsBase
        {
            [Test]
            public void Assure_the_default_true_format_is_used_when_the_value_is_true()
            {
                SetTemplateContent("${message?string}");
                AddTemplateVariable("message", true);

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("true"));
            }

            [Test]
            public void Assure_the_default_false_format_is_used_when_the_value_is_false()
            {
                SetTemplateContent("${message?string}");
                AddTemplateVariable("message", false);

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("false"));
            }

            [Test]
            public void Assure_the_specified_true_format_is_used_when_the_value_is_true()
            {
                SetTemplateContent("${message?string('yes', 'no')}");
                AddTemplateVariable("message", true);

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("yes"));
            }

            [Test]
            public void Assure_the_specified_false_format_is_used_when_the_value_is_false()
            {
                SetTemplateContent("${message?string('yes', 'no')}");
                AddTemplateVariable("message", false);

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("no"));
            }
        }
    }
}
// ReSharper enable InconsistentNaming
